package com.thyrsus.project.dao;

import javax.persistence.EntityManager;

public abstract class IDao<T> {

	public void add(T item) {
		synchronized (this) {
			EntityManager em;

			em = EMFService.get().createEntityManager();
			
			em.getTransaction().begin();
			try {
			    em.persist(item);
			    em.getTransaction().commit();
			} finally {
			    if (em.getTransaction().isActive()) {
			        em.getTransaction().rollback();
			    }
			}
			em.close();
		}
	}
}
